//
//  FFWithdrawContactsCell.m
//  LLWallet
//
//  Created by tt on 2020/9/16.
//

#import "FFWithdrawContactsCell.h"

@implementation FFWithdrawContactsModel

- (Class)cell {
    return FFWithdrawContactsCell.class;
}

@end

@interface FFWithdrawContactsCell ()

@property(nonatomic,strong) UILabel *tipLbl;

@property(nonatomic,strong) UIButton *contactBtn;

@property(nonatomic,strong) FFWithdrawContactsModel *model;

@end

@implementation FFWithdrawContactsCell

+ (CGSize)sizeForModel:(WKFormItemModel *)model {
    return CGSizeMake(WKScreenWidth, 20.0f);
}

- (void)setupUI {
    [super setupUI];
    [self setBackgroundColor:[UIColor clearColor]];
    [self.contentView addSubview:self.tipLbl];
    [self.contentView addSubview:self.contactBtn];
}

- (void)refresh:(FFWithdrawContactsModel *)model {
    [super refresh:model];
    
    self.tipLbl.text = model.tip;
}

- (UILabel *)tipLbl {
    if(!_tipLbl) {
        _tipLbl = [[UILabel alloc] init];
        [_tipLbl setFont:[[WKApp shared].config appFontOfSize:14.0f]];
        [_tipLbl setTextColor:[WKApp shared].config.tipColor];
    }
    return _tipLbl;
}

- (UIButton *)contactBtn {
    if(!_contactBtn) {
        _contactBtn = [[UIButton alloc] init];
        [_contactBtn setTitle:LLang(@"客服") forState:UIControlStateNormal];
        [[_contactBtn titleLabel] setFont:[[WKApp shared].config appFontOfSize:14.0f]];
        [_contactBtn setTitleColor:[WKApp shared].config.themeColor forState:UIControlStateNormal];
        [_contactBtn sizeToFit];
        [_contactBtn addTarget:self action:@selector(contactPressed) forControlEvents:UIControlEventTouchUpInside];
    }
    return _contactBtn;
}

-(void) contactPressed {
    if(self.model.onContactClick) {
        self.model.onContactClick();
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.tipLbl sizeToFit];
    self.tipLbl.lim_left = 15.0f;
    self.tipLbl.lim_top = self.lim_height/2.0f - self.tipLbl.lim_height/2.0f;
    
    self.contactBtn.lim_left = self.tipLbl.lim_right + 4.0f;
    self.contactBtn.lim_top = self.lim_height/2.0f - self.contactBtn.lim_height/2.0f;
    
}

@end
